import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/views/index'
import Product from '@/views/product'
import ProductDetail from '@/views/product/productDetail'
import ProductList from '@/views/product/productList'
import Cart from '@/views/cart'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/',
      redirect: "/index"
    },
    {
      path: '/index',
      component: Index,
    },
    {
      path: '/cart',
      component: Cart
    },
    {
      path: '/product',
      component: Product,
      children: [
        {
          path: '/product',
          redirect: "/product/productList"
        },
        {
          path: '/product/productDetail',
          component: ProductDetail
        },
        {
          path: '/product/productList',
          component: ProductList
        },
      ]
    },
  ]
})

// router.afterEach((to, from) => {
//   console.log(to);
// })

export default router
